// CCboxListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "UsbPhTest.h"
#include "CCboxListCtrl.h"


// CCboxListCtrl

IMPLEMENT_DYNAMIC(CCboxListCtrl, CListCtrl)

CCboxListCtrl::CCboxListCtrl()
{
#ifndef _WIN32_WCE
	EnableActiveAccessibility();
#endif

}

CCboxListCtrl::~CCboxListCtrl()
{
}


BEGIN_MESSAGE_MAP(CCboxListCtrl, CListCtrl)
	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CCboxListCtrl::OnNMCustomdraw)
END_MESSAGE_MAP()



// CCboxListCtrl message handlers




void CCboxListCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
	// TODO: Add your control notification handler code here
    switch (pNMCD->dwDrawStage)
    {
    case CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;

    case CDDS_ITEMPREPAINT:
        *pResult = CDRF_NOTIFYPOSTPAINT;
        break;

    case CDDS_ITEMPOSTPAINT:
    {
        CDC* pDC = CDC::FromHandle(pNMCD->hdc);
        CRect rect;
        m_HeaderCtrl.GetItemRect(0, &rect);

        CRect checkBoxRect = rect;
        checkBoxRect.left += 2;
        checkBoxRect.right = checkBoxRect.left + 16;

        CButton checkBox;
        checkBox.Create(_T("Checkbox"), WS_CHILD | WS_VISIBLE | BS_CHECKBOX, checkBoxRect, &m_HeaderCtrl, 1);

        checkBox.SetCheck(TRUE); // Adjust the check state as needed

        *pResult = CDRF_DODEFAULT;
        break;
    }
    default:
        *pResult = CDRF_DODEFAULT;
        break;
    }
}
